/*
 * @param url 
 * @param {string} title
 * @param {number} width,height
 * @method snail.upper("http://www.baidu.com","�ٶ�",1000);upper("http://www.baidu.com",1000);
 */
var snail={};
(function(){
	//var snail={};
    snail.upper = function(url,title,width,height){
        var t, w, h;
        var app_arg = {
            title: title,
            width:width,
            height:height
        };
        var body = document.body;
        if(!url){
            alert("url不能为空");
            return false;
        }

        if(typeof(app_arg.title) === "string"){
            t = app_arg.title;
            w = app_arg.width;
            h = app_arg.height;
        }else{
            w = app_arg.title;
            h = app_arg.width;
        }
        t = !t ? '' : t;
        w = !w ? parseInt($(window).width()*0.95) : w;
        h = !h ? parseInt($(window).height()*0.95) : h;
        $(document.body).css({"overflow":"hidden"});
        body.style.margin="0px"; var upp_iframe = "<iframe scrolling='auto' frameborder='0' width='"+w+"px' height='"+(h-40)+"px' src='"+url+"'></iframe>";
        var upp_close = "<div  style='position: absolute;z-index:999;cursor:pointer;top: 8px;right: 5px;color: #000;width:20px;height: 20px;font-size: 20px;line-height: 20px;text-align: center;font-family: "+'Microsoft YaHei'+"' onclick='snail.upp_close()'>X</div>";
        var upp_title = "<div style='position: relative;z-index:990;width: 100%;height: 35px;background:#B9B7B7;color:#fff;font-size:16px;font-weight:600;text-align: center;line-height: 35px;margin-bottom: 5px;'>"+t+"</div>";
        var upp_body = "<div style='position: relative;margin: 2% auto;background:#fff;border: solid 1px #0092ED;width: "+w+"px;height:"+h+"px;'>"+upp_close+upp_title+upp_iframe+"</div>";
        var upp_div = "<div id='upp_div' style='position: absolute;   zoom:1;text-align:center;z-index:990;height:100%;width:100%;margin: 0px;)'>"+upp_body+"</div>";
        var upp_div_bg = "<div id='upp_div_bg' style='position: absolute;filter:alpha(opacity=50);opacity:0.5; zoom:1;text-align:center;z-index:888;width:100%;height:100%;margin: 0px;background:#000;)'></div>";
        body.innerHTML = upp_div+upp_div_bg+body.innerHTML;
        var uppDiv=document.getElementById('upp_div');
       
        if(window.addEventListener){
            uppDiv.addEventListener('click',function(e){
                if(e.target.id)
                    snail.upp_close();
            });
        }else if(window.attachEvent){
            uppDiv.attachEvent('onclick',function(e){
                if(window.event.srcElement.id)
                snail.upp_close();
            });
        }else{
            uppDiv.onclick=function(e){stopBubble(e);snail.upp_close();};
        }
    };
    snail.upp_close = function(){
        var body = document.body;
        var uppDiv = document.getElementById('upp_div');
        var uppDivBg = document.getElementById('upp_div_bg');
        body.removeChild(uppDiv);
        body.removeChild(uppDivBg);
        $(document.body).css({"overflow":"auto"});
        
    };

})();

